<template>
  <div class="receive">
    <loading :show="isLoading"></loading>
    <div class="list">
      <template v-if="list.length > 0 ">
        <orderBox v-for="(item, index) in list" :key="index" :item="item" @getList="getList"></orderBox>
      </template>
      <template v-else>
        <no-data></no-data>
      </template>
    </div>
  </div>
</template>

<script>
import { XButton, Icon, Loading  } from "vux";
import AssetApi from "@/api/asset.js";
import orderBox from "../components/order-box.vue";
export default {
  components: {
    XButton,
    Icon,
    Loading,
    orderBox
  },
  data() {
    return {
      list: [],
      isLoading:false
    };
  },
  mounted() {
    this.getList()
  },
  methods: {
    getList() {
      AssetApi.findMyBorrowAll({status:2}).then((res) => {
        if (res.code == "0000") {
          this.list = res.data.records || []
        }
      });
    },
    DetailBtn(item){
      this.$router.push({ name: 'receiveDetail', query: { orderId: item.orderId} });
    },
    // 获取可归还列表
    getLendReceiveList() {
      this.isLoading = true
      let _params = {
        page: 1,
        pageSize: 1000,
      };
      AssetApi.findUnconfirmBorrowAll(_params).then((res) => {
        this.isLoading = false
        if (res.code == "0000") {
          this.list = res.data.records.map((item) => {
            let temp = item;
            temp.check = false;
            return temp;
          });
        }
      });
    },
    confirmReceive(item) {
      let _this = this
      _this.$vux.confirm.show({
        title: "确认接收",
        content: "确认接收后不可更改",
        onCancel() {},
        onConfirm() {
          // _this.isLoading = true
            // AssetApi.orderConfirm({ orderId: item.orderId }).then((res) => {
            //   _this.isLoading = false
            //   if (res.code == "0000") {
            //     _this.$vux.toast.show({
            //       text: "资产接收确认成功",
            //     });
            //     _this.getLendReceiveList()
            //   }
            // });
        },
      });
    },
    submit() {
      this.$vux.toast.show({
          text: "请选择需要接收的资产",
          type: "warn",
        });
      // AssetApi.transferConfirm({ id: ids.toString() }).then((res) => {
      //   if (res.code == "0000") {
      //     this.$vux.toast.show({
      //       text: "资产接收确认成功",
      //     });
      //   }
      // });
    },
  },


};
</script>

<style lang="less" scoped>
.receive{
  padding-bottom:20px;
  .list {
    height: auto;
    background: #f1f1f1;
    padding: 10px;
    margin-bottom: 50px;
  }
}
</style>
